<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 
        定义一个函数，接受一个数组，返回的是数组去重之后的结果；
     -->
</head>

<body>

</body>
<script>
    let arr = [1, 5, 78, 'frt', 1, 1, 78, 56];
    console.log('原数组为', arr);
    console.log('除重后的数组为', deWeight(arr));
    //去重
    function deWeight(arr) {
        for (let i = 0; i < arr.length - 1; i++) {
            for (let j = i + 1; j < arr.length; j++) {
                while (arr[i] == arr[j]) {
                    arr.splice(j, 1);
                    j--;
                }
            }
            // console.log(i, arr);//测试
        }
        return arr;
    }
</script>

</html>